package com.sscaipiao.android.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.sscaipiao.android.R;
import com.sscaipiao.android.common.Constants;
import com.sscaipiao.android.model.User;

public class ThirdPartyActivity extends Activity implements OnClickListener {
	
	private Button backButton;
	private Button finishButton;
	private TextView third_party_title;

	private User user;
	
	private EditText  account;
	private EditText  password;
	
	private String thirdPartyType;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
		.detectDiskReads().detectDiskWrites().detectNetwork()
		.penaltyLog().build());
		StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
		.detectLeakedSqlLiteObjects().detectLeakedClosableObjects()
		.penaltyLog().penaltyDeath().build());

		super.onCreate(savedInstanceState);
		setContentView(R.layout.third_party_login);
		
		Intent i = this.getIntent();
		if (!i.equals(null)) {
			Bundle b = i.getExtras();
			if (b != null) {
				if (b.containsKey(Constants.USER)) {
					user = (User) b.get(Constants.USER);
				}
				if (b.containsKey(Constants.TYPE)) {
					thirdPartyType = (String) b.get(Constants.TYPE);
				}
			}
		}
		
		backButton =  (Button) findViewById(R.id.third_party_button_back);
		finishButton = (Button) findViewById(R.id.third_party_button_finish);
		third_party_title = (TextView)findViewById(R.id.third_party_title); 
		
		if("paypal".equals(thirdPartyType)){
			third_party_title.setText(R.string.paypal_login);
		}
		
		backButton.setOnClickListener(this);
		finishButton.setOnClickListener(this);
		
		account = (EditText)  findViewById(R.id.third_party_txt_account);
		password = (EditText)  findViewById(R.id.third_party_txt_password);
		
	}

	
	@Override
	public void onClick(View v) {
		if(R.id.third_party_button_back == v.getId()) {

			ThirdPartyActivity.this.finish();  
		}
	}
}
